package com.youdianstar.app.entity

import com.youdianstar.app.common.util.StrUtil
import kotlin.math.abs


/**
 * File: MerchantEx
 * Author: 82149 Create: 2024/2/3 17:50
 * Changes (from 2024/2/3)
 * --------------------------------------------------
 * description:
 * ---------------------------------------------------
 *
 */

data class OpTitleLan(
    val en:String = "",
    val zh:String = "",
    val es:String
)

/**商家中心 - 切换商家*/
data class MerchantOP(
    var id: Int,
    var branchName: String = "",
    //形象图片
    var images:String?=null,
    //经纬度
    var lat:Double = 0.0, var lng:Double = 0.0,
    //详细地址信息
    var address:String?=null,
    var code: Int = 0,
    var phone: String = "",
    var landlinePhone: String = "",
    //是否营业 true：营业&&机柜在线 false:不营业/机柜不在线
    var isBusiness:Boolean = false,


    var isSelect: Boolean = false
){
    fun merchantName():String{
        return if (StrUtil.isEmpty(branchName)) "--" else branchName
    }
}


data class OpMerchantHome(

    //订单数-今日
    val todayTotalOrder: Int,
    //分成金额-今日
    val profitToday: Double,
    //分成金额-累计
    val profitTotal: Double,
    //可提现金额
    val pendingAmount: Double,
    //已提现金额
    val settledAmount: Double,
    //订单数-累计
    val totalOrder: Int
)

/**设备对象*/
data class DeviceEntity(

    val id :Int,
    /*创建时间*/
    val createTime: Long,
    /*IMEI 机柜 or PB*/
    val imei:String,
    /**
     * 机柜数据
     */
    //--机柜编号 or PB存在 Cabinet编号
    val cabinetNo: String?=null,
    /*机柜孔位数量*/
    val deviceCount:Int?=null,
    /*可租借数量*/
    val availableNum: Int,
    /*可归还数量*/
    val returnableNum: Int,
    /*已锁定数量*/
    val lockedNum: Int,
    /*低电量数量*/
    val lowBatteryNum: Int,
    //报损次数 机柜
    val damagedNum:Int,
    //异常预警数
    val abnormalCount:Int,

    /*信号值*/
    val signal: String?=null,
    /*小机柜数量*/
    val smallCabinetNum: Int?=null,
    //机柜锁定状态：1-正常 2-锁定 (大机柜没有锁定状态,值为-1),可用值:-1,1,2
    var customizeState: Int?=null,
    /*机柜语言提示：1-开启 0-关闭 (大机柜没有语音,值为-1),可用值:-1,0,1*/
    val soundStatus: Int?=null,
    /*仓位列表*/
//    val posPbList: List<PbSlotInfo>?=null,


    /*所属品牌id*/
    val brandId: Int=-1,
    /*所属代理商id*/
    val agentId: Int=-1,
    val agentName:String?=null,
    /*所属网点id*/
    val branchId: Int=-1,
    val branchName:String?=null,
    val branchPhone:String?=null,

    /**
     * 设备连接状态(1-启用 2-禁用),可用值:1,2
     */
    val connectionState:Int = 0,
    /**
     * 机柜状态: 0-离线 1-在线 2-已迁移,可用值:0,1,2
     */
    val state: Int = 0,

    //0-不带屏 1-带屏
    val isScreen:Int = 0,
    /**
     * 设备类型
     * 机柜类型：1-小机柜 2-大机柜,可用值:1,2
     */
    val type: Int
)

/**商户中心--分成流水*/
data class OpTransaction(
    //流水id
    val id: Int,
    //交易时间
    val createTime: Long,
    //金额
    val amount: Double,
    //订单
    val orderNo :String?=null,
    /**
     * 流水类型：1-订单分成 2-调整 3-退款
     */
    val type: Int,
    //第三方交易号
    val transactionId:String?=null
){
    fun orderIdTx():String{
        return if (StrUtil.isEmpty(orderNo)) "--" else orderNo!!
    }

    fun amountAbs():Double{
        if (amount == 0.0)
            return 0.0
        return abs(amount)
    }
}

/**交易流水*/
data class OpTransCount(
    val profitRefundedTotal: Double,
    val profitTotal: Double
)

/**提现申请接口*/
data class WithdrawsReq(
    val branchId:Int,
    val amount:Double,
    val bankCardId:Long?=null
)

/**提现记录*/
data class WithdrawalRec(
    val id: Int,
    //金额
    val amount: Double,
    //申请时间
    val createTime: Long,
    //交易单号（第三方）
    val transactionId: String?=null,
    //状态：0-申请中 1-已结算 2-驳回申请
    val state: Int,
    //审核人姓名
    val auditName: String?=null,
    //审核人角色
    val auditRole: String?=null,
    //审核时间
    val auditTime: Long,
    //备注
    val remark: String?=null,

    //是否展开 :适配用
    var isExp:Boolean = false
)

//商家中心 -- 行业列表
data class OpIndustry(
    val id:Int,
    //行业名称
    val industryName:OpTitleLan?=null,
    //显示状态：0-不显示 1-显示
    val display:Int,
    //优先级
    val priority:Int,
    //行业描述
    val description:OpTitleLan?=null,
)

//商家中心 -- 网点信息
data class OpShopInfo(
    val id:Int,
    //所属平台 id
    var platformId:Int?=null,
    //代理id
    val agentId:Int?=null,
    //代理名称
    var agentName:String?=null,
    //创建时间
    val createTime:Long,
    var branchName:String?, val branchCode:String?,
    var addressMap:String?, var areaAddress:String?,
    //网点所在时区
    var timeZoneId:String?,
    //经纬度
    var lat:Double, var lng:Double,
    //详细地址信息
    var address:String?,
    //距离,单位：米
    val distance:Int?=null,
    //Logo 与 网点形象照片地址
    var logo :String?, val images:String?,
    var website:String?,
    //座机电话
    var landlinePhone:String?,
    //国家-地区码, 电话
    var code:Int?, var phone:String?,
    //负责人名字
    val principal:String?=null,
    /*分成比例：0-100*/
    val ratio:Int,
    //行业id
    val industryId:Int,
    val industryName:OpTitleLan?=null,
    val description:OpTitleLan?=null,
    //所属账号
    val branchAccount:OpAccount?=null,

    //是否营业 true：营业&&机柜在线 false:不营业/机柜不在线
    val isBusiness:Boolean,
    //营业时间(json)
    var openTime:String?,
    /*0-待激活 1-正常 2-停止合作*/
    val state:Int,
    //总机柜数量, 在线数量 , 离线数量
    val totalNum:Int?=null, val cabOnlineNum:Int?=null, val offLineNum:Int?=null,
    //可租借,可归还数量
    val rent:Int?=null, val recovery:Int?=null,
    //计费规则id
    val billingId:Int,
    val billingTitle:String?,
    val billing : BillingPlan?
){
    fun agentTx():String{
        return if (StrUtil.isEmpty(agentName)) "--" else agentName!!
    }
}

//商家中心 --商家编辑请求
data class OpShopRequest(
    val id: Int?=null,
    //网点名称
    var branchName: String?=null,
    /*Logo图片地址*/
    var logo: String?=null,
    /*网点形象照片地址*/
    var images: String?=null,
    /*手输识别地址*/
    var address: String?=null,
    /*地图地址*/
    var addressMap: String?=null,
    var lat: Double?=null,
    var lng: Double?=null,
    /*区域码与区域地址*/
    var areaCode:Int?=null,
    var areaAddress:String?=null,


    /*营业时间json*/
    var openTime: String?=null,
    /*网点联系电话*/
    var landlinePhone: String?=null,
    //网点-手机国家码
    var code: Int?=null,
    //网点-电话
    var phone: String?=null,
    //负责人名字
    var principal:String?=null,
    //分成比例
    var ratio:Int? = null,
    //行业id
    var industryId:Int? = null,
    //计费规则 id
    var billingId:Int?=null,

    //短信验证码
    var msgCode: String?=null
)

data class OpAccount(
    val id :Int,
    //国家-地区码, 电话
    var code:Int,
    var phone:String,
    val email:String
){
    fun accountTx():String{
        return if (StrUtil.isEmpty(phone)){
            email
        }else{
            "+$code $phone"
        }
    }
}


